#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    int n;
    cin>>n;
    int x,y;
    while(n--){
        char c;
        int d;
        cin>>c>>d;
        if(c=='F')y++;
        else if(c=='B')y--;
        else if(c=='L')x--;
        else x++;
    }
    cout<<x<<" "<<y<<endl;
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    

    return 0;
}